<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="s" uri="http://shiro.apache.org/tags" %>
<div class="table-div">
	<div class="table-operator">
		<button class="btn green formbtn-add">Add</button>
	</div>
	<div class="clearfix"></div>
	<div class="table-filter">&nbsp;</div>
	<div class="table-body">
		<table class="table table-striped table-hover table-bordered "></table>
	</div>
</div>

<script>
	var baseUrl = "rest/admin/role/";
	C.initAjax(baseUrl);
	var $table = $(".table-body>table");
	var tb = $table.DataTable({
				ajax : {
					url : baseUrl + "listData",
					dataSrc : ""
				},
				columns : [
					{
						title:"角色名",
						data:"roleName"
					},
					{
						title:"描述",
						data:"description"
					},
					{
						title:"标示",
						data:"roleSign"
					}
					, {
						title : "操作",
						data : "id",
						createdCell:function(td,tdData){
							var operator = [];
							<s:hasPermission name="/admin/role/delete">
							var delBtn = C.createDelBtn(tdData);
							operator.push(delBtn);
							</s:hasPermission>
							<s:hasPermission name="/admin/role/edit">
							var editBtn = C.createEditBtn(tdData);
							operator.push(editBtn);
							</s:hasPermission>
							<s:hasPermission name="/admin/role/assign">
							operator.push(createAssignBtn(tdData));
							</s:hasPermission>				
							$(td).html(operator);
						}
					} ],
			});
	currentDt = tb;
	
	function createAssignBtn(roleId){
		return C.createFormBtn({
			url:baseUrl+"assign",
			formaction:baseUrl+"assign_form",
			data:{roleId:roleId},
			name:"分配权限"			
		});
	}
	
</script>